<template>
  <div class="wrap">
    <div>
      <el-button type="success" @click="handleEdit('1')">市场部安全员发起</el-button>
      <el-button type="success" @click="handleEdit('2')">商户确认</el-button>
      <el-button type="success" @click="handleEdit('3')">抄送市场部经理确认</el-button>
    </div>
    <!-- <el-steps :active="active" finish-status="success">
      <el-step title="步骤 1">1</el-step>
      <el-step title="步骤 2">2</el-step>
      <el-step title="步骤 3">3</el-step>
    </el-steps>-->
    <div class="tit">
      在安全管理模块，新建工伤管理模块，不再依附于事故管理模块。
      事故VS工伤的逻辑流程：
      <div>1、事务报告</div>
      <div>2、调查分析</div>
      <div>3、防范措施和教育</div>
      <div>4、事故处理</div>
      <div>5、是否认定工伤</div>
      <div>6、是否走审批流程</div>
      <div>安全管理→工区设置→工区的定义要统一→安全管理模块删除工区设置</div>
      <div>安全管理→岗位设置→放在人员信息→岗位设置→安全管理模块删除岗位设置</div>
    </div>

    <div class="img">
      <img
        src="https://files.axshare.com/gsc/ORNHZ6/c6/94/86/c694868284b84228873eafedd8340dbe/images/工伤认定流程_1/u0.png?pageId=0d4f1320-68fb-43d3-925a-36b83902c8fd"
        alt
      />
    </div>

    <el-dialog
      title="违章整改确认"
      :visible.sync="open"
      width="80%"
      :before-close="handleClose"
      v-if="open"
    >
      <el-form
        ref="formValidate"
        :model="formValidate"
        label-width="170px"
        :inline="true"
        class="formValidate mt20"
      >
        <el-form-item
          label="申请人姓名"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="身份证号"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="工作岗位"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-select
            class="hw"
            :disabled="isCreate==2"
            v-model="formValidate.status"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="dict in dict.type.sys_normal_disable"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="发生时间"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-date-picker
            class="hw"
            :disabled="isCreate==2"
            v-model="formValidate.dateRange"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['00:00:00', '23:59:59']"
          ></el-date-picker>
        </el-form-item>
        <el-form-item
          label="发生地点"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="原因经过"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="受伤部位"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="严重程度"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="救治医院"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="诊断结果"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="实际花费"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-input
            class="hw"
            v-model="formValidate.homeName"
            :disabled="isCreate==2"
            placeholder="请输入"
            clearable
          />
        </el-form-item>
        <el-form-item
          label="工伤认定"
          prop="homeName"
          :rules="{ required: true, message: '请输入', trigger: 'blur' }"
        >
          <el-select
            class="hw"
            :disabled="isCreate==2"
            v-model="formValidate.status"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="dict in dict.type.sys_normal_disable"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <el-dialog title="查看照片" :visible.sync="lookImgPop" width="60%" append-to-body>
        <lookImg type="2" @close="lookImgPop=false"></lookImg>
      </el-dialog>
      <div class="bt" style="text-align: center;" v-if="type==1">
        <el-button
          style="width:100px"
          type="primary"
          @click="submitForm('formValidate')"
          v-if="isCreate!=2"
        >下一步</el-button>
        <el-button style="width:100px" @click="handleClose">取消</el-button>
      </div>
      <div class="bt" style="text-align: center;" v-if="type==2||type==3">
        <el-button style="width:100px" type="primary" @click="submitForm('formValidate')">确认</el-button>
        <el-button style="width:100px" @click="handleClose">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import lookImg from "./com/img.vue";
import {
  listUser,
  getUser,
  delUser,
  addUser,
  updateUser,
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect
} from "@/api/system/user";
export default {
  components: {
    lookImg
  },
  dicts: ["sys_normal_disable"],
  data() {
    return {
      radio: "0",
      single: true,
      lookImgPop: false,
      total: 0,
      userList: [],
      loading: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        deptId: undefined
      },
      open: false,
      formValidate: {},
      isCreate: 0
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    lookImg() {
      this.lookImgPop = true;
    },
    childrenData(e) {
      console.log(e, "www");
    },
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
        response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    submitForm() {
      console.log(this.formValidate, "这是什么呀?");
      return;
      if (this.isCreate === 0) {
        //新增
        this.$refs.formValidate.validate(valid => {
          this.formValidate.medalId = this.formValidate.medalId.toString();
          console.log(this.formValidate, "this.formValidatethis.formValidate");
          if (valid) {
            homeGetAdd(this.formValidate).then(res => {
              this.$message.success("提交成功");
              this.$emit("getList");
              this.$emit("close");
            });
          }
        });
      }

      if (this.isCreate === 1) {
        //编辑
        this.formValidate.medalId = this.formValidate.medalId.toString();
        console.log(this.formValidate, "2this.formValidatethis.formValidate");
        this.$refs.formValidate.validate(valid => {
          if (valid) {
            homeGetEdit(this.formValidate).then(res => {
              this.$message.success("提交成功");
              this.$emit("getList");
              this.$emit("close");
            });
          }
        });
      }
    },
    handleEdit(type) {
      if (type == 1) {
        this.isCreate = 0;
      } else {
        this.isCreate = 2;
      }
      this.type = type;
      this.open = true;
    },
    handleClose() {
      if (this.type == 1) {
        this.open = false;
      } else {
        console.log("做个啥事在关闭");
        this.open = false;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.hw {
  width: 280px;
}
.wrap {
  width: 80%;
  margin: 0 auto;

  .tit {
    width: 20%;
    margin: 30px auto;
  }
  .img {
    text-align: center;
  }
}
</style>